//
//  HZAmotionBtn.swift
//  weibo002
//
//  Created by 黑眼圈 on 16/4/28.
//  Copyright © 2016年 heiyan. All rights reserved.
//

import UIKit

class HZAmotionBtn: UIButton {
    
    
    
    var value:HZEmotionModel?{
        
        
        didSet{
            
            //如果是 emoji 表情
            if value!.type == "1" {
                
                let str = (value!.code! as NSString).emoji()
                
                self.setTitle(str, forState: .Normal)
                self.setImage(nil , forState: .Normal)
            }else {
                // 如果是其他表情
                let img = UIImage(named: "\(value!.pathString ?? "")/\(value!.png ?? "")", inBundle: HZEmotionVM.sharedEmotion.getBundle(), compatibleWithTraitCollection: nil)
                
                self.setImage(img , forState: .Normal)
                self.setTitle(nil, forState: .Normal)
            }

            
        }
        
    }
}
